package cn.edu.gench.learn.service;

import cn.edu.gench.learn.dao.BookDao;
import cn.edu.gench.learn.model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.MessageFormat;
import java.util.List;

/**
 * Created by Administrator on 2017/4/28.
 */
@Service
public class BookService {

    @Autowired
    private BookDao bookDao;



    public List<Book> getBooks() {
        return bookDao.queryAll();
    }

    public Book getBookById(int id) {
        return bookDao.queryBookById(id);
    }

    public Book update(int id, String name) {
        //更新
        bookDao.updateNameById(id,name);
        //查询
        return  getBookById(id);

    }

    public Book delete(int id) {
        bookDao.delete(id);
        return  getBookById(id);
    }

    public String test(int id, String name) {
        System.out.println(MessageFormat.format("service=> id = {0} ,name = {1}",id,name));
        return bookDao.test(id,name);
    }




























}
